﻿function setMenu(url) {
    var jurisdiction = Number(window.localStorage.getItem("jurisdiction"));
    var tMenu = {
        "panels": [{
            "children": [{
                "title": "菜单",
                "callBack": "doSetm",
                "icon": url + "/image/open.png",
                "param": "2",
                "height": 115,
                "width": 270
            }],
            "left": 775,
            "title": "open",
            "top": -1,
            "bottom": 0,
            "right": -1,
            "visible": "false",
            "direction": "wh"
        }, {
            "children": [{
                "title": "用户信息",
                "callBack": "",
                "icon": url + "/image/toolR1.png",
                "param": "",
                "height": 44,
                "width": 44
            }],
            "left": -1,
            "title": "yh",
            "top": 12,
            "bottom": -1,
            "right": 84,
            "visible": "true",
            "direction": "wh"
        }]
    };
    //测试
    var urls= loginUrl + '/menu?id=' + jurisdiction;
    
    //var url = "http://192.168.1.38:31200/menu?id=2"
    $.ajax({
        url: urls,
        type: 'post',
        async: false,
        success: function (data) {
            var left = 820;
            var homepage = {
                userModule: data[0].userModule,
                information: data[0].information,
                dscene: data[0].dscene,
                modelManagement: data[0].modelManagement,
                visualization: data[0].visualization,
                dataManagement: data[0].dataManagement,
                externalManagement: data[0].externalManagement
            }
            if (data.length > 0) {
                var dat = data[0];
                if (dat.userModule == "true") {
                    var cans = {
                        "children": [{
                            "title": "用户管理",
                            "callBack": "doop",
                            "icon": url + "/image/menu1.png",
                            "param": "1",
                            "height": 63,
                            "width": 70
                        }],
                        "left": left,
                        "title": "cp",
                        "top": 3,
                        "bottom": -1,
                        "right": -1,
                        "visible": "true",
                        "direction": "wh"
                    };
                    left = left + 120;
                    tMenu.panels.push(cans);
                }
                if (dat.information == "true") {
                    var cans = {
                        "children": [{
                            "title": "信息模型",
                            "callBack": "doop",
                            "icon": url + "/image/menu2.png",
                            "param": "2",
                            "height": 63,
                            "width": 70
                        }],
                        "left": left,
                        "title": "yy",
                        "top": 3,
                        "bottom": -1,
                        "right": -1,
                        "visible": "true",
                        "direction": "wh"
                    };
                    left = left + 120;
                    tMenu.panels.push(cans);
                }
                if (dat.dscene == "true") {
                    var cans = {
                        "children": [{
                            "title": "三维场景",
                            "callBack": "doop",
                            "icon": url + "/image/menu3.png",
                            "param": "3",
                            "height": 63,
                            "width": 70
                        }],
                        "left": left,
                        "title": "jk",
                        "top": 3,
                        "bottom": -1,
                        "right": -1,
                        "visible": "true",
                        "direction": "wh"
                    };
                    left = left + 120;
                    tMenu.panels.push(cans);
                }
                if (dat.modelManagement == "true") {
                    var cans = {
                        "children": [{
                            "title": "模块管理",
                            "callBack": "doop",
                            "icon": url + "/image/menu4.png",
                            "param": "4",
                            "height": 63,
                            "width": 70
                        }],
                        "left": left,
                        "title": "zljc",
                        "top": 3,
                        "bottom": -1,
                        "right": -1,
                        "visible": "true",
                        "direction": "wh"
                    };
                    left = left + 120;
                    tMenu.panels.push(cans);
                }
                if (dat.visualization == "true") {
                    var cans = {
                        "children": [{
                            "title": "可视化",
                            "callBack": "doop",
                            "icon": url + "/image/menu5.png",
                            "param": "5",
                            "height": 63,
                            "width": 70
                        }],
                        "left": left,
                        "title": "yxjk",
                        "top": 3,
                        "bottom": -1,
                        "right": -1,
                        "visible": "true",
                        "direction": "wh"
                    };
                    left = left + 120;
                    tMenu.panels.push(cans);
                }
                if (dat.dataManagement == "true") {
                    var cans = {
                        "children": [{
                            "title": "数据管理",
                            "callBack": "doop",
                            "icon": url + "/image/menu6.png",
                            "param": "5",
                            "height": 63,
                            "width": 70
                        }],
                        "left": left,
                        "title": "xtgl",
                        "top": 3,
                        "bottom": -1,
                        "right": -1,
                        "visible": "true",
                        "direction": "wh"
                    };
                    left = left + 120;
                    tMenu.panels.push(cans);
                }
                if (dat.externalManagement == "true") {
                    var cans = {
                        "children": [{
                            "title": "外部管理",
                            "callBack": "doop",
                            "icon": url + "/image/menu6.png",
                            "param": "6",
                            "height": 63,
                            "width": 70
                        }],
                        "left": left,
                        "title": "xtgl",
                        "top": 3,
                        "bottom": -1,
                        "right": -1,
                        "visible": "true",
                        "direction": "wh"
                    };
                    left = left + 120;
                    tMenu.panels.push(cans);
                }
                //子菜单
                if (dat.menu.userModule) {
                    if (dat.menu.userModule.length > 0) {
                        var lis = {
                            "children": [],
                            "left": 15,
                            "title": "c1",
                            "top": 75,
                            "bottom": -1,
                            "right": -1,
                            "visible": "false",
                            "direction": "wh"
                        };
                        for (var j = 0; j < dat.menu.userModule.length; j++) {
                            var zicd = {
                                "title": dat.menu.userModule[j].title,
                                "callBack": dat.menu.userModule[j].callback,
                                "icon": url + dat.menu.userModule[j].icon,
                                "param": dat.menu.userModule[j].param,
                                "height": 30,
                                "width": 40
                            }
                            lis.children.push(zicd);
                        }
                        tMenu.panels.push(lis);
                    }
                }
                if (dat.menu.information) {
                    if (dat.menu.information.length > 0) {
                        var lis = {
                            "children": [],
                            "left": 15,
                            "title": "c2",
                            "top": 75,
                            "bottom": -1,
                            "right": -1,
                            "visible": "false",
                            "direction": "wh"
                        };
                        for (var j = 0; j < dat.menu.information.length; j++) {
                            var zicd = {
                                "title": dat.menu.information[j].title,
                                "callBack": dat.menu.information[j].callback,
                                "icon": url + dat.menu.information[j].icon,
                                "param": dat.menu.information[j].param,
                                "height": 30,
                                "width": 40
                            }
                            lis.children.push(zicd);
                        }
                        tMenu.panels.push(lis);
                    }
                }
                if (dat.menu.dscene) {
                    if (dat.menu.dscene.length > 0) {
                        var lis = {
                            "children": [],
                            "left": 15,
                            "title": "c3",
                            "top": 75,
                            "bottom": -1,
                            "right": -1,
                            "visible": "false",
                            "direction": "wh"
                        };
                        for (var j = 0; j < dat.menu.dscene.length; j++) {
                            var zicd = {
                                "title": dat.menu.dscene[j].title,
                                "callBack": dat.menu.dscene[j].callback,
                                "icon": url + dat.menu.dscene[j].icon,
                                "param": dat.menu.dscene[j].param,
                                "height": 30,
                                "width": 40
                            }
                            lis.children.push(zicd);
                        }
                        tMenu.panels.push(lis);
                    }
                }
                if (dat.menu.modelManagement) {
                    if (dat.menu.modelManagement.length > 0) {
                        var lis = {
                            "children": [],
                            "left": 15,
                            "title": "c4",
                            "top": 75,
                            "bottom": -1,
                            "right": -1,
                            "visible": "false",
                            "direction": "wh"
                        };
                        for (var j = 0; j < dat.menu.modelManagement.length; j++) {
                            var zicd = {
                                "title": dat.menu.modelManagement[j].title,
                                "callBack": dat.menu.modelManagement[j].callback,
                                "icon": url + dat.menu.modelManagement[j].icon,
                                "param": dat.menu.modelManagement[j].param,
                                "height": 30,
                                "width": 40
                            }
                            lis.children.push(zicd);
                        }
                        tMenu.panels.push(lis);
                    }
                }
                if (dat.menu.visualization) {
                    if (dat.menu.visualization.length > 0) {
                        var lis = {
                            "children": [],
                            "left": 15,
                            "title": "c5",
                            "top": 75,
                            "bottom": -1,
                            "right": -1,
                            "visible": "false",
                            "direction": "wh"
                        };
                        for (var j = 0; j < dat.menu.visualization.length; j++) {
                            var zicd = {
                                "title": dat.menu.visualization[j].title,
                                "callBack": dat.menu.visualization[j].callback,
                                "icon": url + dat.menu.visualization[j].icon,
                                "param": dat.menu.visualization[j].param,
                                "height": 30,
                                "width": 40
                            }
                            lis.children.push(zicd);
                        }
                        tMenu.panels.push(lis);
                    }
                }
                if (dat.menu.dataManagement) {
                    if (dat.menu.dataManagement.length > 0) {
                        var lis = {
                            "children": [],
                            "left": 15,
                            "title": "c6",
                            "top": 75,
                            "bottom": -1,
                            "right": -1,
                            "visible": "false",
                            "direction": "wh"
                        };
                        for (var j = 0; j < dat.menu.dataManagement.length; j++) {
                            var zicd = {
                                "title": dat.menu.dataManagement[j].title,
                                "callBack": dat.menu.dataManagement[j].callback,
                                "icon": url + dat.menu.dataManagement[j].icon,
                                "param": dat.menu.dataManagement[j].param,
                                "height": 30,
                                "width": 40
                            }
                            lis.children.push(zicd);
                        }
                        tMenu.panels.push(lis);
                    }
                }
                if (dat.menu.externalManagement) {
                    if (dat.menu.externalManagement.length > 0) {
                        var lis = {
                            "children": [],
                            "left": 15,
                            "title": "c7",
                            "top": 75,
                            "bottom": -1,
                            "right": -1,
                            "visible": "false",
                            "direction": "wh"
                        };
                        for (var j = 0; j < dat.menu.externalManagement.length; j++) {
                            var zicd = {
                                "title": dat.menu.externalManagement[j].title,
                                "callBack": dat.menu.externalManagement[j].callback,
                                "icon": url + dat.menu.externalManagement[j].icon,
                                "param": dat.menu.externalManagement[j].param,
                                "height": 30,
                                "width": 40
                            }
                            lis.children.push(zicd);
                        }
                        tMenu.panels.push(lis);
                    }
                }
            }
        },
        error: function (error) {
            console.log(error)
        }
    });
    TBAX.setFullBtn2(JSON.stringify(tMenu));
}
function createhomepage() {
    
}